import { PrimitiveType, PlainObject } from './base';
import { RecordDTO } from './dto';

// 条件Model
export interface QueryPageModel extends PlainObject {
  pageNo: number;
  pageSize: number;
}

export interface QueryHotColumnModel extends PlainObject {
  count: number;
}

export interface QueryTagModel extends PlainObject {
  getCount?: boolean;
}

export interface QueryCategoryModel extends PlainObject {
  getCount?: boolean;
}

export interface QueryCommentPageModel extends QueryPageModel {
  id?: number; // 文章id
}

export interface QueryCommentModel extends PlainObject {
  site_url: string | undefined;
  nick_name: string | undefined;
  content: string;
  article_id?: number;
  email: string;
  jump_url: string;
}

export interface QueryReplyModel extends PlainObject {
  site_url: string | undefined;
  nick_name: string | undefined;
  content: string;
  article_id?: number;
  email: string;
  jump_url: string;
  parent_id: null | number;
  comment_id: number;
}

export interface QuerySearchModel extends PlainObject {
  keyword: string;
}

export interface QueryNumberModel extends PlainObject {
  id: number;
}

export interface LoginModel extends PlainObject {
  userName: string;
  password: string;
  captcha: string;
}

// 响应Model
export interface CommonResponse<T = unknown> {
  code: string;
  extra?: PlainObject | null;
  msg?: string;
  data?: T | T[];
}

export interface PageResponse<T extends RecordDTO> extends CommonResponse {
  data: T[];
  total: number;
}

// 数组响应
export interface ArrayResponse<T extends RecordDTO> extends CommonResponse {
  data: T[];
}

// 普通响应
export interface PlainResponse<T extends PrimitiveType> extends CommonResponse {
  data: T;
}

export interface ObjectResponse<T extends RecordDTO> extends CommonResponse {
  data: T;
}
